package com.jdd.enterprise.domain.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
//import com.jdd.common.base.container.PageRequest;
import com.jdd.enterprise.api.dto.PageRequest;
import com.jdd.enterprise.api.vo.PageResponse;
import com.jdd.enterprise.domain.entity.CookingMethod;
import com.jdd.enterprise.domain.mapper.CookingMethodMapper;
import com.jdd.enterprise.util.PageUtil;
import com.zaxxer.hikari.util.ConcurrentBag;
import org.checkerframework.checker.units.qual.C;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CookingMethodService  extends ServiceImpl<CookingMethodMapper, CookingMethod> {

    @Autowired

    private CookingMethodMapper cookingMethodMapper;


    public PageResponse<CookingMethod> showList(PageRequest<CookingMethod> request) {
        CookingMethod param = request.getParam();

        LambdaQueryWrapper<CookingMethod> wrapper = Wrappers.lambdaQuery(CookingMethod.class);


        if(ObjectUtils.isNotEmpty(param.getMethodName())){
            wrapper.like(CookingMethod::getMethodName,param.getMethodName());
        }
        List<CookingMethod> cookingMethods = cookingMethodMapper.selectList(wrapper);


        PageResponse<CookingMethod> page = PageUtil.createPage(request.getCurrentPage(), request.getPageSize());
        PageUtil.refreshData(page, (long) cookingMethods.size(),cookingMethods);






        return  page;



    }
}
